Simple Math for Projectile Motion

(You Know: Missiles and Basketballs and Stuff!)

by Tomas J. Nally

Steelweaver52@aol.com


Home

Tip Corner

API Corner

Qcard DLL #5

Sprite Byte

Projectile Motion

Sub Handlers

Agent Lesson

LB Server

A Web Presence

Website Review

An Interview

DoubleClick

Disk Cleaner

Newsletter help

Index

Introduction

Objects thrown or shot into the air (projectiles) follow a path that is parabolic. That is, the path of the object can be described by an equation of this form:

y = A*x^2 + B*x + C     (Eq. P1)

where

y = the vertical coordinate of the object in space
x = the horizontal coordinate of the object in space
and
A, B, and C are constants

Understanding the math of parabolic motion is important if, say, you want to write a program involving missiles or canonballs being fired in an environment influenced by gravity.


But to arrive at that equation, let's first discuss the math of the motion of a ball thrown straight up into the air. After that, let's discuss the math of the motion of a ball rolled along the ground at constant speed. Then, we will combine the math from these two discussions, and we will ultimately arrive at the parabolic equation shown above.

As you read through this article, it may seem a little "math intensive". Have patience, however. In the end there is an example program that helps you calculate parabolic motion very simply!

The Importance of the Element of "Time"

Equations of motion often involve the element of time. Often we want to know the speed of an object, which is the distance an object covers over a given time. On other occasions, we want to know an object's location at a particular point in time. As you will see below, time will be the independent variable in the equations for both vertical motion and horizontal motion. (See the sidebar, above and right, for a note on independent and dependent variables.)


Tossing a Ball Into The Air

If we toss a ball straight up into the air, we can predict its height (or y-coordinate) at any time, t, with the following formula:

y = y0 + vy0*t + (1/2)*g*t^2     (Eq. P2)

where

y   = the height of the ball at any time, t
t   = the current time in seconds (the independent variable)
y0  = the initial y-coordinate at the time t = 0
vy0 = the initial vertical velocity at time t = 0
and
g   = the acceleration due to gravity, usually -32.2 feet/second

Notice that g is a negative number. Even though the motion of the ball is upward through the first half of its path, its acceleration due to gravity is always downward. That is because the force of gravity is downward, or toward the center of the Earth.

The values in Table 1 shown on the right were calculated using Equation P2. In the table, y0 = 10 feet, vy0 = 45 feet/sec, and g = -32.2 feet/sec^2. The variable t (for time) is the independent variable, and it is listed in increments of two-tenths of a second. The dependent variable y (for height) is given for each value of t. Notice that the object continues to rise for the first 1.4 seconds, at which time it reaches its peak height of 41.4 feet. After it has reached its peak, it starts to fall back to earth. After 3 seconds have elapsed, the ball has nearly completed its "round trip" path and is only 0.1 feet above the ground.

Notice also how the ball's velocity changes constantly. In the time between t = 0.0 and t = 0.2, the ball moves a total distance of 8.4 feet. However, between the time t = 1.2 and t = 1.4, the ball has slowed down considerably, and only gains 0.6 feet in that time interval. That's exactly how gravity effects the path of a ball thrown into the air! It starts out fast, and gradually slows until it reaches its peak height, and then it falls back to the earth picking up speed as it descends. At the end of its path (between 2.8 and 3.0 seconds), it drops a total of 9.7 feet!


Okay, we've explored the motion that occurs when we toss a ball straight up into the air. Now let's look at a ball rolled across the floor at constant speed (horizontal motion). Notice again that time, t, serves as the independent variable.

Rolling a Ball Across the Floor

If we roll a ball across the floor and neglect any slowing of the ball due to friction, we can predict its horizontal location (or x-coordinate) at any time, t, with the following formula:

x = x0 + vx0*t     (Eq. P3)

where

x   = the horizontal location of the ball at any time, t
t   = the current time in seconds (the independent variable)
x0  = the initial x-coordinate at the time t = 0
and 
vx0 = the initial horizontal velocity at time t = 0

The values in Table 2 shown on the right were generated using Equation P3. The constants used in Table 2 are x0 = 5 feet, and vx0 = 8 feet/sec.

Notice two things about the values in Table 2 that make them different from the values in Table 1. First, the y-values in Table 1 reached a peak, and then started to decrease as the ball fell back to the earth. In Table 2, the x-values show no such reversal in direction.

Second, Table 2 shows that the ball moves by exactly the same amount in every single time interval. That is, in the time interval between 0.0 and 0.2, the ball moves 1.6 feet. Likewise, in the time interval between 0.2 and 0.4, the ball moves exactly 1.6 feet again. The horizontal movement in all time intervals is identical, unlike the vertical ball movement shown in Table 1. (In fact, this was an initial condition defined at the beginning of this section: horizontal velocity would be constant.)

Combining Horizontal and Vertical Motion

Realize that we have determined the vertical location (y) of a ball tossed into the air using Equation P2, and the horizontal location (x) of a ball using Equation P3. These two formulas do not rely on each other to any extent. The only thing that is common between the two formulas is this: time is used as the independent variable in each formula. For convenience, we also used the same time increment -- two-tenths of a second -- in the two tables of data that we generated using these formulas.

Despite the fact that Equations P2 and P3 are independent, if we combine the data from the two formulas, we get a very interesting result. Table 3 below features three columns of data. The first column represents the time, t, in increments of two-tenths of a second. The second column contains the x-coordinates of the ball at time, t, copied from Table 2. The third column contains the y-coordinates of the ball at time, t, copied from Table 1. The chart shown to the right of Table 3 is a graph of the x-coordinate of the ball versus the y-coordinate of the ball. This graph shows the parabolic path of an object shot or thrown into the air, under the effects of gravity!

The point about projectile (parabolic) motion is this:

When a projectile follows a path through the air, the x-coordinate of the projectile is determined by Equation P3, the same formula used to describe a ball rolling across the floor. The y-coordinate of the projectile is determined by Equation P2, the formula used to describe a ball thrown straight up in the air. These formulas are independent of each other. But combined, they give us parabolic motion.

So, how do we arrive at the formula for parabolic motion, Equation P1?

y = A*x^2 + B*x + C     (Eq. P1, repeated)

Equation P1 is developed by first solving Equation P3 for t.

x = x0 + vx0*t        (Eq. P3, repeated)

t = (x - x0)/vx0      (Eq. P4)

Next, we substitute this value for t into Equation P2:

y = y0 + vy0*t + (1/2)*g*t^2     (Eq. P2, repeated)

y = y0 + vy0*((x - x0)/vx0) + (1/2)*g*((x - x0)/vx0)^2      (Eq. P5)

If we multiply out Equation P5 and collect and rearrange the terms, we get Equation P6.

y = (g/(2*vx0^2))*x^2 + (vy0/vx0 - g*x0/vx0^2)*x + (y0 - vy0*x0/vx0 + g*x0^2/(2*vx0^2))     (Eq. P6)

It's a little hard to tell, but Equation P6 is identical to Equation P1, except that the terms A, B and C are fully defined in Equation P6:

A = (g/(2*vx0^2))
B = (vy0/vx0 - g*x0/vx0^2)
C = (y0 - vy0*x0/vx0 + g*x0^2/(2*vx0^2))

Notice that all the terms in A, B and C are constants. There are no x, y, or t variables.

Whereas Equation P2 gave us y in terms of t, and Equation P3 gave us x in terms of t, Equation P6 gives us y in terms of x. That is, time, t, is not the independent variable in Equation 6. Instead, x is the independent variable, and y is the dependent variable.

Equation 6 was developed merely to show that putting Equations P2 and P3 together will yield the formula for the parabola in Equation P1 as we claimed at the top of the article. In your Liberty BASIC programs, though, you will probably find Equation P2 and Equation P3 to be the most useful of all the equations shown on this page. In fact, let's provide an example below!

Shooting a Basketball

Let's say that as we shoot a basketball, it leaves our hand at the coordinates x = 24, and y = 8. We shoot the ball at a 40 degree angle, and at an initial velocity of 20 feet/second as it leaves our fingertips.

How do we write a BASIC program to calculate the path of this ball in the first 1.2 seconds after it has left our fingertips?

First, even though it is not given, we already know the value of gravity:

g = -32.2

Next, the information above already gives us the initial x- and y-coordinates of the ball at time = zero:

x0 = 24
y0 = 8

We know the ball's initial velocity at an angle of 40 degrees, but we have to find out how much of this velocity is in the upward, or y, direction, and how muck of this velocity is in the horizontal, or x, direction. This is not as hard as it sounds:

pi = 3.14159                                 'define pi
angleDegrees = 40                            'shooting angle, in degrees
angleRadians = (angleDegrees/360) * 2 * pi   'shooting angle, in radians
velocity = 20                                'define the velocity
vx0 = velocity * cos(angleRadians)           'velocity component in the x-direction
vy0 = velocity * sin(angleRadians)           'velocity component in the y-direction

All the constants are now calculated. The only remaining task now is to find the x- and y-coordinates of the basketball at any time, t, using [[b Equation P2] and [[b Equation P3]:

for t = 0.0 to 1.2 step 0.1
    xball = x0 + vx0*t                   'Equation P3
    yball = y0 + vy0*t + (1/2)*g*t^2     'Equation P2
    print "time = "; t; " xball = "; xball; " yball = "; yball
next t

Complete BASIC Program For the Path of a Basketball

Below is provided a complete BASIC program which can be copied into the LB editor:

'BASIC Program to calculate the
'path of a basketball in flight

pi = 3.14159       'Define pi
g = -32.2          'Define the gravitational constant

x0 = 24            'Ball's initial x-coordinate at time = 0
y0 = 8             'Ball's initial y-coordinate at time = 0

velocity = 20      'Initial velocity of the ball as it
                   'leaves the shooter's fingertips

angleDegrees = 40  'shooting angle, in degrees


angleRadians = (angleDegrees/360) * 2 * pi   'shooting angle, in radians
vx0 = velocity * cos(angleRadians)           'velocity component in the x-direction
vy0 = velocity * sin(angleRadians)           'velocity component in the y-direction

print "Ball Path Results"
print "-----------------"

for t = 0.0 to 1.2 step 0.1
    xball = x0 + vx0*t                   'Equation P3
    yball = y0 + vy0*t + (1/2)*g*t^2     'Equation P2
    print "time = "; using("##.##",t);
    print "   xball = "; using("##.##",xball);
    print "   yball = "; using("##.##",yball)
next t

print "   "
input "Press RETURN to end program"; AAA$

end

BASIC Program Output

Below is the output from the program given above. Notice that the x-coordinate of the ball changes by 1.53 feet every tenth of a second (unless rounding errors show something slightly different). Meanwhile, the y-coordinate of the basketball reaches a peak height of 10.57 feet at time = 0.40 seconds. After that, it drops rapidly until it's only 0.24 feet above the floor at time = 1.20 seconds.

Ball Path Results
-----------------
time =  0.00   xball = 24.00   yball =  8.00
time =  0.10   xball = 25.53   yball =  9.12
time =  0.20   xball = 27.06   yball =  9.93
time =  0.30   xball = 28.60   yball = 10.41
time =  0.40   xball = 30.13   yball = 10.57
time =  0.50   xball = 31.66   yball = 10.40
time =  0.60   xball = 33.19   yball =  9.92
time =  0.70   xball = 34.72   yball =  9.11
time =  0.80   xball = 36.26   yball =  7.98
time =  0.90   xball = 37.79   yball =  6.53
time =  1.00   xball = 39.32   yball =  4.76
time =  1.10   xball = 40.85   yball =  2.66
time =  1.20   xball = 42.39   yball =  0.24

Press RETURN to end program


Home

Tip Corner

API Corner

Qcard DLL #5

Sprite Byte

Projectile Motion

Sub Handlers

Agent Lesson

LB Server

A Web Presence

Website Review

An Interview

DoubleClick

Disk Cleaner

Newsletter help

Index